# %%
from conn import ac_task_col
from tqdm import tqdm
from datetime import datetime

# %%

query = {"status": {"$in": [1, 2]}}
total = ac_task_col.count_documents(query)
print(total)

# %%
for task in tqdm(ac_task_col.find(query, {"task_name": 1}), total=total):
    name = task["task_name"]
    idx = name.rfind("]")
    if idx == -1:
        continue
    date = name[idx - 10 : idx]
    try:
        datetime.strptime(date, "%Y-%m-%d")
    except ValueError:
        continue
    priority = 5
    if date.startswith("2025-"):
        priority = 2
    elif date.startswith("2024-11") or date.startswith("2024-12"):
        priority = 3
    print(date, priority)
    ac_task_col.update_one(
        {"_id": task["_id"]},
        {"$set": {"priority": priority}},
    )
